package org.linlinjava.litemall.db.service;

import org.linlinjava.litemall.db.dao.AgedmallLgBaseInfoMapper;
import org.linlinjava.litemall.db.domain.AgedmallLgBaseInfo;
import org.linlinjava.litemall.db.domain.AgedmallLgBaseInfoExample;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class AgedmallLgBaseInfoService {
    @Resource
    private AgedmallLgBaseInfoMapper agedmallLgBaseInfoMapper;

    public void add(AgedmallLgBaseInfo agedmallLgBaseInfo) {
        agedmallLgBaseInfoMapper.insertSelective(agedmallLgBaseInfo);
    }

    /**
     * 根据单号及类型获取物流的基本信息
     * @param orderCode
     * @param lgType
     * @return
     */
    public AgedmallLgBaseInfo getBaseInfoByOrderCode(String orderCode, Integer lgType) {
        AgedmallLgBaseInfoExample example = new AgedmallLgBaseInfoExample();
        example.createCriteria().andOrderCodeEqualTo(orderCode).andLgTypeEqualTo(lgType);
        List<AgedmallLgBaseInfo> baseInfoList = agedmallLgBaseInfoMapper.selectByExample(example);
        return baseInfoList.size() > 0 ? baseInfoList.get(0) : null;
    }
}
